using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class AudioPlayer : MonoBehaviour {
	
	public AudioClip[] audioClips;
	private static AudioClip[] staticAudioClips;
	
	private static AudioSource[] audioSources;
	
	public static int GAME_SOUNDTRACK = 0;
	public static int PLAYER_BOOST = 1;
	public static int PLAYER_LASER = 2;
	public static int PLAYER_WOOF = 3;
	public static int CAT_ATTACK = 4;
	public static int CAT_BLOW = 5;
	public static int CAT_DAMAGED = 6;
	public static int CAT_JUMP = 7;
    public static int COIN = 8;
	
	void Start () {
		
		staticAudioClips = audioClips;
		
		for (int i = 0; i < audioClips.Length; i++) {
		
			this.gameObject.AddComponent<AudioSource>();
		}
	
		audioSources = this.gameObject.GetComponents<AudioSource>();
		
		for (int i = 0; i < audioClips.Length; i++) {
		
			audioSources[i].clip = this.audioClips[i];
		}

		DontDestroyOnLoad(this.gameObject);
		
	}
	

	public static void Play(int index)
	{
		if(staticAudioClips[index] != null)
		{
			audioSources[index].Play();
		}
	}
}
